import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    redirect: '/layout'
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login/login.vue'),
  },
  {
    path: '/layout',
    name: 'layout',
    component: () => import('../components/layout.vue'),
    redirect: '/home',
    children: [
      {
        path: '/home',
        name: 'home',
        component: () => import('../views/home'),
      },
      {
        path: '/member',
        name: 'member',
        meta: {title: '会员管理'},
        component: () => import('../views/member'),
      },
      {
        path: '/supplier',
        name: 'supplier',
        meta: {title: '供应商管理'},
        component: () => import('../views/supplier'),
      },
      {
        path: '/goods',
        name: 'goods',
        meta: {title: '商品管理'},
        component: () => import('../views/goods'),
      },
      {
        path: '/staff',
        name: 'staff',
        meta: {title: '员工管理'},
        component: () => import('../views/staff'),
      },
    ]
  },
  {
    path: '*',
    redirect: '/home'
  },
];

const router = new VueRouter({
  routes,
});

export default router;
